<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateSystemUserTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('system_user', function (Blueprint $table) {
            $table->increments('id')->comment('ID');
            $table->string('role_ids',30)->nullable()->default(null)->comment('角色id集');
            $table->string('head_img',200)->nullable()->comment('头像');
            $table->string('username',30)->comment('用户名');
            $table->string('nickname',30)->nullable()->comment('昵称');
            $table->char('password',60)->comment('密码');
            $table->string('salt',13)->comment('盐值');
            $table->string('mobile',16)->comment('手机号');
            $table->string('remark',255)->nullable()->comment('备注');
            $table->string('last_login_ip',64)->nullable()->comment('上次登录IP');
            $table->dateTime('last_login_time')->nullable()->comment('上次登录时间');
            $table->integer('login_num')->default(0)->comment('登录次数');
            $table->integer('sort')->default(99)->comment('排序');
            $table->tinyInteger('status')->default(1)->comment('状态');
            $table->dateTime('created_at')->nullable()->comment('创建时间');
            $table->dateTime('updated_at')->nullable()->comment('更新时间');
            $table->dateTime('deleted_at')->nullable()->comment('删除时间');
            $table->index('username','username');
            $table->index('mobile','mobile');
            $table->comment('系统用户表');
        });
    }
    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('system_user');
    }
}
